<?php
/**
 * CreateTime: 2022/6/21 15:47
 */

namespace App\ServiceChecker\newContract;

use App\Consts\BaseConsts\BaseConsts;
use App\Consts\ResponseConsts\ResponseStatusConsts;
use App\Func\ResponseFunc;
use App\Models\NewContract\FulfillmentNodeModel;
use App\ServiceChecker\BasicServiceChecker;
use Illuminate\Http\Exceptions\HttpResponseException;

class FulfillmentNodeExceptionLegitimacy extends BasicServiceChecker
{
    private $fulfillmentNodeModel;

    public function __construct()
    {
        parent::__construct();
        $this->fulfillmentNodeModel = new FulfillmentNodeModel();
    }

    public function verifyFulfillmentNodeIsExists($fulfillmentNodeId){
        $isExists = $this->fulfillmentNodeModel->isExistByCondition([
            'fulfillment_node_id' => $fulfillmentNodeId,
            'status' => BaseConsts::STATUS_NORMAL
        ]);
        if(!$isExists){
            throw new HttpResponseException( ResponseFunc::returnJson(
                'error',
                null,
                "当前履约节点不存在",
                ResponseStatusConsts::OK_200_RESPONSE_STATUS,
            ));
        }
    }

}